{% extends "layout.html" %}
{% block body %}
    {% if session.logged_in %}
        <form action="{{ url_for("add_entry") }}" method="post" class="add-entry">
            <dl>
                <dt><label for="title">Title:</label></dt>
                <dd><input type="text" size="30" name="title" id="title"/></dd>
                <dt><label for="text">Title:</label></dt>
                <dd><textarea name="text" id="text" cols="38" rows="5"></textarea></dd>
            </dl>
            <input type="submit" value="Share"/>
        </form>
    {% endif %}

    <ul class="entries">
        {% for entry in entries %}
            {# 这里使用safe可以保证尖括号，不被转义         #}
            <li><h2>{{ entry.title }}</h2>{{ entry.text|safe }}</li>
        {% else %}
            <li>Unbelievable. No entries here so far</li>
        {% endfor %}
    </ul>
{% endblock %}